<!--
 * @Descripttion: 
 * @Version: 1.0
 * @Author: wcl
 * @Date: 2023-11-21 16:54:39
 * @LastEditors: wcl
 * @LastEditTime: 2023-11-24 10:43:01
-->
<template>
  <div class="container">
    <a-space direction="vertical" style="width: 100%" :size="16">
      <a-card style="width: 100%" title="商品参数管理">
        <a-form :model="formState">
          <a-row :gutter="24">
            <a-col :span="6">
              <a-form-item label="类目名称">
                <a-input
                  style="width: 100%"
                  v-model:value="formState.name"
                  placeholder="输入类目名称"
                />
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item label="状态">
                <a-select
                  ref="select"
                  v-model:value="formState.subCategoryId"
                  style="width: 100%"
                  placeholder="状态"
                >
                  <a-select-option :value="0">全部</a-select-option>
                  <a-select-option :value="1">启用</a-select-option>
                  <a-select-option :value="0">禁用</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>

        <div class="layout-flexSpace">
          <a-space wrap>
            <a-button type="primary" @click="handleSearch">查询</a-button>
            <a-button @click="handleReset">重置</a-button>
          </a-space>
        </div>
      </a-card>

      <a-card>
        <a-table
          :dataSource="dataSource"
          :columns="paramsColumns"
          :pagination="pagination"
          @change="handleChangeSize"
        >
          <template #bodyCell="{ column, record }">
            <template v-if="column.key === 'operate'">
              <a-space>
                <a-button type="primary" @click="handelAdd(record)"
                  >参数管理</a-button
                >
                <a-button danger type="primary" @click="handleEdit(record)"
                  >禁用</a-button
                >
              </a-space>
            </template>
          </template>
        </a-table>
      </a-card>
    </a-space>
    <paramsAdmin ref="brandRef" />
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { paramsColumns } from "./columns.js";
import paramsAdmin from "./categoryModule/parameters/paramsAdmin.vue";
const total = ref(0);
const pagination = ref({
  current: 1,
  pageSize: 10,
  defaultPageSize: 10,
  total: total.value,
  showSizeChanger: true,
  pageSizeOptions: ["10", "20", "50", "100"],
  showTotal: () => `共 ${total.value} 条`,
});
const formState = ref({
  page: pagination.value.current,
  pageSize: pagination.value.pageSize,
  categoryId: undefined,
  subCategoryId: undefined,
  searchCondition: undefined,
  status: undefined,
});
const brandRef = ref(null);
const dataSource = ref([
  {
    name: "腕表",
    grouping: "1",
    classHeading: "2",
    sort: "1",
    status: "1",
  },
]);
function handleSearch() {
  formState.value.page = 1;
  formState.value.pageSize = 10;
  getGoodsApplyList();
}
const handelAdd = (titles) => {
  brandRef.value.open(titles);
};

function handleReset() {
  formState.value = {
    page: 1,
    pageSize: 10,
    categoryId: undefined,
    subCategoryId: undefined,
    searchCondition: undefined,
    status: undefined,
  };
  pagination.value.current = 1
  pagination.value.pageSize = 10
}

function handleExport() {}
function handleChangeSize(page) {
  formState.value.page = page.current;
  formState.value.pageSize = page.pageSize;
  pagination.value.current = page.current;
  pagination.value.pageSize = page.pageSize;
}
</script>

<style lang="less">
.img-item {
  display: flex;
  flex-direction: column;
  align-items: center;

  .img-label {
    margin-top: 6px;
    color: #9599a5;
    font-size: 12px;
  }
}
</style>
